/*
 * 文件名：LogAdvice.java
 * 版权：Copyright by will_awoke
 * 描述：Spring AOP
 * 修改人：lyh
 * 修改时间：2013-09-27
 * 跟踪单号：
 * 修改单号：
 * 修改内容：
 */
package com.qbgs.aop;


import org.apache.log4j.Logger;
import org.aspectj.lang.JoinPoint;


/**
 * 
 * Spring AOP
 * @author lyh
 * @version 2013-09-27
 * @see LogAdvice
 * @since
 */
public class LogAdvice
{
    /**
     * 日志
     */
    private static final Logger LOG = Logger.getLogger(LogAdvice.class);

    /**
     * 
     * Description: 方法后调用AOP
     * 
     * @param jp 
     * @see
     */
    public void doAfter(JoinPoint jp)
    {
        if (LOG.isDebugEnabled())
        {
            LOG.info("log Ending method: " + jp.getTarget().getClass().getName() + "." + jp.getSignature().getName());
        }
    }

    /**
     * 
     * Description: 方法前调用AOP
     * 
     * @param jp 
     * @see
     */
    public void doBefore(JoinPoint jp)
    {
        if (LOG.isDebugEnabled())
        {
            LOG.info("log Begining method: " + jp.getTarget().getClass().getName() + "." + jp.getSignature().getName());
        }
    }

    /**
     * 
     * Description: 发生异常后调用AOP
     * 
     * @param jp JoinPoint
     * @param ex 
     * @see
     */
    public void doThrowing(JoinPoint jp, Throwable ex)
    {
        if (LOG.isDebugEnabled())
        {
            LOG.error("method " + jp.getTarget().getClass().getName() + "." + jp.getSignature().getName() + " throw exception");
            LOG.error(ex.toString() + "：" + ex.getMessage());
        }
    }
}
